package com.sunday.pinxinghui.model.mine;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sunday.common.base.BaseActivity;
import com.sunday.common.model.ResultDO;
import com.sunday.common.utils.ToastUtils;
import com.sunday.pinxinghui.R;
import com.sunday.pinxinghui.entity.Rule;
import com.sunday.pinxinghui.network.ApiClient;

import butterknife.Bind;
import butterknife.ButterKnife;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by 刘涛 on 2017/8/30.
 */

public class IntegralRuleActivity extends BaseActivity {


    @Bind(R.id.title_view)
    TextView titleView;
    @Bind(R.id.content)
    TextView content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_integral_rule);
        ButterKnife.bind(this);
        titleView.setText("积分规则");
        getRules();
    }

    private void getRules(){
        Call<ResultDO<Rule>> call= ApiClient.getApiAdapter().getScoreRule();
        call.enqueue(new Callback<ResultDO<Rule>>() {
            @Override
            public void onResponse(Call<ResultDO<Rule>> call, Response<ResultDO<Rule>> response) {
                if (isFinish||response.body()==null){return;}
                if (response.body().getCode()==0){
                    content.setText(response.body().getResult().getRole());
                }else {
                    ToastUtils.showToast(mContext,response.body().getMessage());
                }
            }

            @Override
            public void onFailure(Call<ResultDO<Rule>> call, Throwable t) {
                ToastUtils.showToast(mContext,R.string.network_error);
            }
        });
    }


}
